package com.ruirenyun.util.oss;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Description 阿里云配置
 * @Author hp
 * @Date 2020/9/14 17:25
 * @Version 1.0
 */
@Data
@ConditionalOnProperty(prefix = "aliyun", name = {"accessKeyId", "accessKeySecret", "bucketName", "resource"})
@Component
public class AliyunConfig {

    @Value("${aliyun.bucketName}")
    private String bucketName;

    @Value("${aliyun.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.accessKeySecret}")
    private String accessKeySecret;
    @Value("${aliyun.resource}")
    private String resource;

    @PostConstruct
    public void init() {
        OssUtil.setAliyunConfig(this);
    }

}
